Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE ember-views-component-block-info] #10461

Merged
merged 1 commit into from
Feb 15, 2015

Conversation

rwjblue
Copy link
Member

@rwjblue rwjblue commented Feb 14, 2015

Adds a couple utility methods to detect block/block param presence:

  • hasBlock

    Adds the ability to easily detect if a component was invoked with or
    without a block.

    Example (hasBlock will be false):

    {{! templates/application.hbs }}
    
    {{foo-bar}}
    
    {{! templates/components/foo-bar.js }}
    {{#if hasBlock}}
      This will not be printed, because no block was provided
    {{/if}}

    Example (hasBlock will be true):

    {{! templates/application.hbs }}
    
    {{#foo-bar}}
      Hi!
    {{/foo-bar}}
    
    {{! templates/components/foo-bar.js }}
    {{#if hasBlock}}
      This will be printed because a block was provided
      {{yield}}
    {{/if}}
  • hasBlockParams

    Adds the ability to easily detect if a component was invoked with block parameter
    supplied.

    Example (hasBlockParams will be false):

    {{! templates/application.hbs }}
    
    {{#foo-bar}}
      Hi!.
    {{/foo-bar}}
    
    {{! templates/components/foo-bar.js }}
    {{#if hasBlockParams}}
      {{yield this}}
      This will not be printed, because no block was provided
    {{/if}}

    Example (hasBlockParams will be true):

    {{! templates/application.hbs }}
    
    {{#foo-bar as |foo|}}
      Hi!
    {{/foo-bar}}
    
    {{! templates/components/foo-bar.js }}
    {{#if hasBlockParams}}
      {{yield this}}
      This will be printed because a block was provided
    {{/if}}

Closes #10319.

@@ -18,7 +18,8 @@
"ember-application-instance-initializers": null,
"ember-application-initializer-context": null,
"ember-router-willtransition": true,
"ember-application-visit": null
"ember-application-visit": null,
"ember-views-component-has-block": null
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Derp. Forgot to update the feature flag name. Will update shortly...

Adds a couple utility methods to detect block/block param presence:

* `hasBlock`

  Adds the ability to easily detect if a component was invoked with or
  without a block.

  Example (`hasBlock` will be `false`):

  ```hbs
  {{! templates/application.hbs }}

  {{foo-bar}}

  {{! templates/components/foo-bar.js }}
  {{#if hasBlock}}
    This will not be printed, because no block was provided
  {{/if}}
  ```

  Example (`hasBlock` will be `true`):

  ```hbs
  {{! templates/application.hbs }}

  {{#foo-bar}}
    Hi!
  {{/foo-bar}}

  {{! templates/components/foo-bar.js }}
  {{#if hasBlock}}
    This will be printed because a block was provided
    {{yield}}
  {{/if}}
  ```

* `hasBlockParams`

Adds the ability to easily detect if a component was invoked with block parameter
supplied.

Example (`hasBlockParams` will be `false`):

```hbs
{{! templates/application.hbs }}

{{#foo-bar}}
  Hi!.
{{/foo-bar}}

{{! templates/components/foo-bar.js }}
{{#if hasBlockParams}}
  {{yield this}}
  This will not be printed, because no block was provided
{{/if}}
```

Example (`hasBlockParams` will be `true`):

```hbs
{{! templates/application.hbs }}

{{#foo-bar as |foo|}}
  Hi!
{{/foo-bar}}

{{! templates/components/foo-bar.js }}
{{#if hasBlockParams}}
  {{yield this}}
  This will be printed because a block was provided
{{/if}}
```
@rwjblue rwjblue force-pushed the ember-views-component-has-block branch from 076655f to a986881 Compare February 14, 2015 21:03
@rwjblue rwjblue changed the title [FEATURE ember-views-component-block-param-info] [FEATURE ember-views-component-block-info] Feb 14, 2015
@rwjblue
Copy link
Member Author

rwjblue commented Feb 14, 2015

Updated documentation, and fixed incorrect feature flag name.

mmun added a commit that referenced this pull request Feb 15, 2015
[FEATURE ember-views-component-block-info]
@mmun mmun merged commit 4183594 into emberjs:master Feb 15, 2015
@mmun mmun deleted the ember-views-component-has-block branch February 15, 2015 16:50
@kottenator
Copy link

As I understand, the feature is broken in Ember v1.12.0

{{#if hasBlock}} doesn't work as expected, {{#if template}} does work, but it's deprecated.

Please, check if I'm right ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Default block for components that use yield
3 participants